package com.qjl.shopping.exception;

import com.qjl.shopping.common.ResponseEntity;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @Author liguanghui
 * @Date 2023/4/24
 */
@ControllerAdvice
public class GlobalExceptionHandler {
    @ExceptionHandler(ServiceException.class)
    @ResponseBody
    public ResponseEntity handle(ServiceException se){
        return ResponseEntity.error(se.getCode(), se.getMessage());
    }
}
